.checkbox-primary,
.radio-primary {
  display: block;
  position: relative;

  > input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    z-index: 3;
    width: 20px;
  }

  > label {
    padding-left: 25px;
    cursor: pointer;
    font-weight: normal;

    &:before,
    &:after {
      display: block;
      content: ' ';
      position: absolute;
      left: 0;
      top: 2px;
      right: 0;
      width: 16px;
      height: 16px;
      border-radius: 2px;
      text-align: center;
      line-height: 16px;
    }

    &:after {
      border: 1px solid @color-gray;
      z-index: 1;
      background: #fff;
      transition: @animation-speed-normal @animation-type;
      transition-property: border, background-color;
    }

    &:before {
      .icon;
      content: @icon-check;
      z-index: 2;
      top: 3px;
      opacity: 0;
      transform: scale(0);
      transition: @animation-speed-fast @animation-type;
      transition-property: opacity, transform;
    }
  }

  > input:checked + label,
  &.checked > label {
    &:after {
      border-color: @color-primary;
      border-width: 4px;
      background-color: @color-primary;
    }

    &:before {
      color: white;
      opacity: 1;
      transform: scale(1);
    }
  }

  &.indeterminate > label,
  input:indeterminate + label {
    &:after {
      width: 8px;
      height: 2px;
      background-color: #A3A2BC;
      opacity: 1;
      transform: scale(1);
      content: ' ';
      top: 14px;
      left: 3px;
    }
  }

  &.focus > label,
  > input:focus + label {
    &:after {
      box-shadow: 0 0 8px @color-primary;
      border-color: @color-primary;
    }
  }

  &.disabled > label,
  input:disabled + label {
    &:after {
      background-color: #e5e5e5;
      border-color: #bbb;
    }
  }

  &.checked.disabled > label,
  input:disabled:checked + label {
    &:after {
      background-color: #bbb;
    }
  }
}

.radio-primary {
  > label {
    &:after {
      border-radius: 50%;
    }

    &:before {
      content: ' ';
      width: 6px;
      height: 6px;
      border-radius: 50%;
      border: none;
      top: 7px;
      left: 5px;
    }
  }

  > input:checked + label,
  &.checked > label {
    &:after {
      border-color: @color-primary;
      border-width: 2px;
      background-color: #fff;
    }

    &:before {
      background-color: @color-primary;
    }
  }

  &.checked.disabled > label,
  input:disabled:checked + label {
    &:after {
      background-color: #fff;
      border-color: #bbb;
    }

    &:before {
      background-color: #bbb;
    }
  }
}
